#include <bits/stdc++.h>
using namespace std;
class Solution {
    public:
        int strStr(string haystack, string needle) {
            // return haystack.find(needle); 
            int m=haystack.size(),n=needle.size();
            if(m<n)return -1;
            for(int i=0;i<=m-n;i++)
            {
                int k=i;
                int j=0;
                while(j<n&&haystack[k]==needle[j])
                {
                    k++,j++;
                }
                if(!needle[j])return i;
            }
            return -1;
        }
    };
    class Solution {
        public:
            int strStr(string haystack, string needle) {
                // return haystack.find(needle); 
                int m=haystack.size(),n=needle.size();
                if(m<n)return -1;
                for(int i=0;i<=m-n;i++)
                {
                    int k=i;
                    int j=0;
                    while(j<n&&haystack[k]==needle[j])
                    {
                        k++,j++;
                    }
                    if(!needle[j])return i;
                }
                return -1;
            }
        };